# script pour interrogation alarme protexiom
  
hget () {
    eval echo '${hash'"$1"'#hash}'
}
. /etc/cmh-ludl/protexiom_profile
#---------------------------------------------------------------------------------
[ -f $cookiefile ] && rm $cookiefile 
fromSP=$(curl $SPip 2>/dev/null | grep "<b>"|awk -F"<b>" '{print $2}'|cut -c1-2)
#echo "KeyAuthent="$fromSP" PassAuthent="$(hget $fromSP) #Debug Pass Auth
if  [ "$fromSP" = "(0x0902)" ]; then
        echo "Somfy Protexion Busy... Try Again Later"
        echo "Error Code="$fromSP
else
	SPkey=$(hget $fromSP)
	varWget="login=u&password="$SPpass"&key="$SPkey"&action=Connexion&img.x=51&img.y=14"
        varlogin=$SPip"m_login.htm"
        varWgetactiv="zone=Arr%eat%20A%20B%20C"
        varmuactivate=$SPip"mu_pilotage.htm"
        varlogout=$SPip"m_logout.htm"
        curl  -L -b $cookiefile -c $cookiefile  -X POST --data $varWget $varlogin   2>/dev/null > /dev/null
        curl  -L -b $cookiefile -c $cookiefile  -X POST --data $varWgetactiv $varmuactivate  2>/dev/null > /dev/null
	curl -b $cookiefile  $varlogout 2>/dev/null > /dev/null
fi
